package com.github.aloxc.plugin.restplus.entity;

import com.github.aloxc.plugin.DonotGuard;

import java.io.Serializable;
import java.util.Map;

/**
 * 用例
 * @author liyh
 */
@DonotGuard
public class UserCase implements Serializable {
    private static final long serialVersionUID = -5485441761235922020L;
    @DonotGuard
    private Map<String,Object> headerMap;
    @DonotGuard
    private Map<String,Object> paramMap;
    @DonotGuard
    private Map<String,Object> bodyMap;
    @DonotGuard
    private String test;



    public UserCase(Map<String, Object> headerMap, Map<String, Object> paramMap, Map<String, Object> bodyMap,String test) {
        this.headerMap = headerMap;
        this.paramMap = paramMap;
        this.bodyMap = bodyMap;
        this.test = test;
    }

    public UserCase() {
    }

    public String getTest() {
        return test;
    }

    public void setTest(String test) {
        this.test = test;
    }

    public Map<String, Object> getHeaderMap() {
        return headerMap;
    }

    public void setHeaderMap(Map<String, Object> headerMap) {
        this.headerMap = headerMap;
    }

    public Map<String, Object> getParamMap() {
        return paramMap;
    }

    public void setParamMap(Map<String, Object> paramMap) {
        this.paramMap = paramMap;
    }

    public Map<String, Object> getBodyMap() {
        return bodyMap;
    }

    public void setBodyMap(Map<String, Object> bodyMap) {
        this.bodyMap = bodyMap;
    }

    /**
     * 获取userCaseKey
     * @param name
     * @param method
     * @return
     */
    public static String getUserCaseKey(String name,String method){
        return name + "-" + method;
    }


    /**
     * 获取userCase Name
     * @param key
     * @return
     */
    public static String getUserCaseName(String key){
        int i = key.lastIndexOf("-");
        return key.substring(0,i);
    }

    /**
     * 获取userCase Name
     * @param key
     * @return
     */
    public static String getUserCaseMethod(String key){
        int i = key.lastIndexOf("-");
        return key.substring(i+1);
    }
//
//    public static void main(String[] args) {
//        String key = "abc-def-ghi-post";
//        System.out.println(getUserCaseMethod(key));
//    }
}
